package org.apache.ibatis.common.logging.log4j2;

import org.apache.ibatis.common.logging.Log;
import org.apache.ibatis.common.logging.LogFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

/**
 * @Name Log4j2LoggerImpl
 * @Description: Log4jImpl 具体实现类
 * @Version v1.0.0
 * @Author: lichao
 * @Date: 2024-05-15 15:47:26
 **/
public class Log4j2LoggerImpl implements Log {
    private static final Marker MARKER = MarkerManager.getMarker(LogFactory.MARKER);
    private final Logger logger;

    public Log4j2LoggerImpl(Logger logger) {
        this.logger = logger;
    }

    @Override
    public boolean isDebugEnabled() {
        return logger.isDebugEnabled();
    }

    @Override
    public boolean isTraceEnbaled() {
        return logger.isTraceEnabled();
    }

    @Override
    public void error(String msg, Throwable e) {
        logger.error(MARKER, msg, e);
    }

    @Override
    public void error(String msg) {
        logger.error(MARKER, msg);
    }

    @Override
    public void warn(String msg) {
        logger.warn(MARKER, msg);
    }

    @Override
    public void debug(String msg) {
        logger.debug(MARKER, msg);
    }

    @Override
    public void trace(String msg) {
        logger.trace(MARKER, msg);
    }
}

